Author: k l
Last saved by: Adam

Ken's Korner
By Ken Lill
About 1986

The purpose of this series of articles is to add some knowledge to readers that may be in the dark about some of the basic no-no's of programming!

     One thing that can save an awful lot of space in making programs that have a lot of BOX commands is to make a BOX-making sub-routine.

     An example of what not to do is:

        100 BOX 0,-65,8,8,1;BOX 0,-63,8,8,2;BOX 0,-61,8,8,3,110;
            BOX 0,-59,8,8,1;BOX 0-,57,8,8,2;BOX 0,-55,8,8,3

     This can be done in a subroutine like this:

          5 BOX A,B,D,E,F;RETURN 
        100 A=0;B=-65;C=8;D=8;E=1;GOSUB 5;B=-63;E=2;GOSUB 5
        110 B=-61;E=3;GOSUB 5;B=-59;E=1;GOSUB 5;B=-57;E=2;GOSUB 5;
            B=-55;E=3;GOSUB 5

     This doesn't look to be saving any good amount of bytes, but if you have quite a few boxes within other lines, all that you need to do is set the variables up prior to your going to the subroutine!

     There are two other ways to save even more bytes:

     1) If you'll notice the X numbers in the commands are the same in
        each case, as well as the Y size.  The Y position and the color
        type are the only changes and they both follow a pattern, so they
        can be used in a loop, like this:

           100 A=0;C=8;D=8;B=-67;FOR F=0TO 1;FOR E=1TO 3;B=B+2;GOSUB 5;
               NEXT E;NEXT F

        The above line uses up 49 bytes.  Line 5 has 15 bytes.  The original
        line used up 73.  That is a savings of 9 bytes just for the one line.
        If you have multiple lines with different size boxes, the savings can
        be quite substantial.

     2) To save even more bytes, the variables can be pre-saved onto tape.
        Astro BASIC saves all variables.  All of the Extended BASICs can also
        save their variables to tape.

        To do this in the 300 Baud Bally BASIC (#6002), you will need to
        do this procedure:

           :PRINT;PRINT "A=0;B=-67;C=0;D=0";:RETURN 

        This will instruct the BASIC to load the variables after it loads the
        body of the program.

        Now the line looks like this:

           100 FOR F=0TO 1;FOR E=1TO 3;B=B+2;GOSUB 5;NEXT E;NEXT F

        This saves an additional 18 bytes.  When you only have 1800 as in the
        Bally and Astro BASICs, this savings can help get all of the program
        you want.

        Just make sure that your first line number is less than 5 and that it
        says to "GOTO" any line number greater than 5!

Notes about this particular column:

Paul Thacker has been archiving Bally Arcade/Astrocade tape programs since about 2005.  On May 6, 2012, Paul Thacker made a posting to the Bally Alley discussion group called, "Long-lost Kenz Korner column."  Paul said, "Ken Lill once did a column for the Arcadian. I've looked through a few tapes from Ken Lill's collection, and on one I found an unpublished column. It was in BASIC format (probably to be loaded into a word processing program on a RAM expansion), but fortunately the text came out readable in the .bml file. Ken thought this was probably written soon before the Arcadian stopped publishing. It has some tips for saving space in your programs. The version I found stopped after "NOW THE LINE LOOKS LIKE THIS:", but Ken finished it up for us."